/*     */ package com.lmpop.trade.ti_newscomment;
/*     */ 
/*     */ import com.lmpop.frame.QueryList;
/*     */ import com.lmpop.frame.SysMap;
/*     */ import com.lmpop.frame.TradeInterf;
/*     */ import com.lmpop.frame.dao.DbmInterf;
/*     */ import com.lmpop.frame.dao.IbatisDbmImpl;
/*     */ import com.lmpop.frame.exp.ApplicationException;
/*     */ import com.lmpop.frame.util.RandomID;
/*     */ import java.util.Hashtable;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ 
/*     */ public class Ti_newscommentInfo
/*     */   implements TradeInterf
/*     */ {
/*     */   QueryList queryList;
/*     */ 
/*     */   public Ti_newscommentInfo()
/*     */   {
/*  17 */     this.queryList = new QueryList();
/*     */   }
/*     */ 
/*     */   public SysMap insert(DbmInterf dbmMgr, SysMap map)
/*     */   {
/*  26 */     RandomID randomID = new RandomID();
/*  27 */     String info_id = randomID.GenTradeId();
/*  28 */     String result_code = "0";
/*  29 */     String result_info = "";
/*  30 */     String ch_id = map.getString("ch_id");
/*  31 */     if (ch_id.length() >= 16) {
/*  32 */       ch_id = ch_id.substring(ch_id.length() - 16, ch_id.length() - 1);
/*     */     }
/*  34 */     String userrand = map.getString("userrand");
/*  35 */     String randcode = map.getString("randcode");
/*  36 */     if ((!userrand.equals("")) && (!userrand.trim().equals(randcode.trim()))) {
/*  37 */       result_info = "您输入的验证码不正确!";
/*  38 */       result_code = "1";
/*     */     }
/*     */     else {
/*  41 */       Ti_newscomment ti_newscomment = new Ti_newscomment();
/*  42 */       ti_newscomment.setInfo_id(info_id);
/*  43 */       ti_newscomment.setNews_id(map.getString("news_id"));
/*  44 */       ti_newscomment.setCh_id(ch_id);
/*  45 */       ti_newscomment.setIn_date(map.getString("in_date"));
/*  46 */       ti_newscomment.setContent(map.getString("content"));
/*  47 */       ti_newscomment.setUser_id(map.getString("session_user_id"));
/*  48 */       ti_newscomment.setUp_num(map.getInt("up_num"));
/*  49 */       ti_newscomment.setDown_num(map.getInt("down_num"));
/*     */       try
/*     */       {
/*  53 */         insert(dbmMgr, ti_newscomment);
/*     */       } catch (ApplicationException e) {
/*  55 */         e.printStackTrace();
/*  56 */         result_code = "1";
/*     */       }
/*     */     }
/*  59 */     map.setString("result_code", result_code);
/*  60 */     map.setString("result_info", result_info);
/*  61 */     return map;
/*     */   }
/*     */ 
/*     */   public void insert(DbmInterf dbmMgr, Ti_newscomment ti_newscomment)
/*     */     throws ApplicationException
/*     */   {
/*  70 */     dbmMgr.update("insertTi_newscomment", ti_newscomment);
/*     */   }
/*     */ 
/*     */   public SysMap delete(DbmInterf dbmMgr, SysMap map)
/*     */   {
/*  80 */     String pkid_string = map.getString("pkid");
/*  81 */     String result_code = "0";
/*     */     try {
/*  83 */       if (!pkid_string.equals("")) {
/*  84 */         String[] pkStr = pkid_string.split("\\|");
/*  85 */         for (int i = 0; i < pkStr.length; i++) {
/*  86 */           if (pkStr[i].equals("")) continue; delete(dbmMgr, pkStr[i]);
/*     */         }
/*     */       }
/*     */     } catch (ApplicationException e) {
/*  90 */       e.printStackTrace();
/*  91 */       result_code = "1";
/*     */     }
/*  93 */     map.setString("result_code", result_code);
/*  94 */     return map;
/*     */   }
/*     */ 
/*     */   public void delete(DbmInterf dbmMgr, String pkid)
/*     */     throws ApplicationException
/*     */   {
/* 103 */     dbmMgr.update("deleteTi_newscomment", pkid);
/*     */   }
/*     */ 
/*     */   public SysMap update(DbmInterf dbmMgr, SysMap map)
/*     */   {
/* 112 */     Ti_newscomment ti_newscomment = new Ti_newscomment();
/* 113 */     ti_newscomment.setInfo_id(map.getString("info_id"));
/* 114 */     ti_newscomment.setNews_id(map.getString("news_id"));
/* 115 */     ti_newscomment.setCh_id(map.getString("ch_id"));
/* 116 */     ti_newscomment.setIn_date(map.getString("in_date"));
/* 117 */     ti_newscomment.setContent(map.getString("content"));
/* 118 */     ti_newscomment.setUser_id(map.getString("user_id"));
/* 119 */     ti_newscomment.setUp_num(map.getInt("up_num"));
/* 120 */     ti_newscomment.setDown_num(map.getInt("down_num"));
/*     */ 
/* 122 */     String result_code = "0";
/*     */     try {
/* 124 */       update(dbmMgr, ti_newscomment);
/*     */     } catch (ApplicationException e) {
/* 126 */       e.printStackTrace();
/* 127 */       result_code = "1";
/*     */     }
/* 129 */     map.setString("result_code", result_code);
/* 130 */     return map;
/*     */   }
/*     */ 
/*     */   public void update(DbmInterf dbmMgr, Ti_newscomment ti_newscomment)
/*     */     throws ApplicationException
/*     */   {
/* 139 */     dbmMgr.update("updateTi_newscomment", ti_newscomment);
/*     */   }
/*     */ 
/*     */   public List getListByPage(Object obj, int start, int limit)
/*     */   {
/* 149 */     Ti_newscomment ti_newscomment = (Ti_newscomment)obj;
/* 150 */     if (start == 0)
/* 151 */       start = 0;
/*     */     else {
/* 153 */       start = (start - 1) * limit;
/*     */     }
/*     */ 
/* 156 */     ti_newscomment.setStart(Integer.valueOf(start));
/* 157 */     ti_newscomment.setLimit(Integer.valueOf(limit));
/* 158 */     return this.queryList.getList("getListByTi_newscommentPage", ti_newscomment);
/*     */   }
/*     */ 
/*     */   public int getCountByObj(Object obj)
/*     */   {
/* 169 */     Ti_newscomment ti_newscomment = (Ti_newscomment)obj;
/*     */ 
/* 171 */     List list = this.queryList.getList("getCountByObjTi_newscomment", ti_newscomment);
/* 172 */     int count = 0;
/* 173 */     if ((list != null) && (list.size() > 0)) {
/* 174 */       Hashtable newsMap = (Hashtable)list.get(0);
/* 175 */       if ((newsMap.get("count") != null) && (!newsMap.get("count").toString().equals(""))) {
/* 176 */         count = Integer.parseInt(newsMap.get("count").toString());
/*     */       }
/*     */     }
/* 179 */     return count;
/*     */   }
/*     */ 
/*     */   public List getListByPk(String pk)
/*     */   {
/* 190 */     return this.queryList.getList("getTi_newscommentByPk", pk);
/*     */   }
/*     */ 
/*     */   public String getUseridById(String info_id)
/*     */   {
/* 203 */     String user_id = "";
/* 204 */     List list = this.queryList.getList("getUseridById", info_id);
/* 205 */     if ((list != null) && (list.size() > 0)) {
/* 206 */       Map map = (Hashtable)list.get(0);
/* 207 */       if (map.get("user_id") != null) {
/* 208 */         user_id = map.get("user_id").toString();
/*     */       }
/*     */     }
/*     */ 
/* 212 */     return user_id;
/*     */   }
/*     */ 
/*     */   public List getListByTi_newscomments(Object obj, int start, int limit)
/*     */   {
/* 222 */     Hashtable ti_newscomment = (Hashtable)obj;
/* 223 */     if (start == 0)
/* 224 */       start = 0;
/*     */     else {
/* 226 */       start = (start - 1) * limit;
/*     */     }
/* 228 */     ti_newscomment.put("start", Integer.valueOf(start));
/* 229 */     ti_newscomment.put("limit", Integer.valueOf(limit));
/*     */ 
/* 231 */     return this.queryList.getList("getListByTi_newscomments", ti_newscomment);
/*     */   }
/*     */ 
/*     */   public int getCountByID(Object obj)
/*     */   {
/* 241 */     Hashtable ti_newscomment = (Hashtable)obj;
/*     */ 
/* 243 */     List list = this.queryList.getList("getCountByTi_newscommentID", ti_newscomment);
/* 244 */     int count = 0;
/* 245 */     if ((list != null) && (list.size() > 0)) {
/* 246 */       Hashtable newsMap = (Hashtable)list.get(0);
/* 247 */       if ((newsMap.get("count") != null) && (!newsMap.get("count").toString().equals(""))) {
/* 248 */         count = Integer.parseInt(newsMap.get("count").toString());
/*     */       }
/*     */     }
/* 251 */     return count;
/*     */   }
/*     */ 
/*     */   public void changeNesCommentNums(Map map)
/*     */   {
/* 263 */     DbmInterf dbmMgr = new IbatisDbmImpl();
/*     */ 
/* 265 */     String method = "";
/* 266 */     String info_id = "";
/*     */ 
/* 269 */     int up_num = 0;
/* 270 */     int down_num = 0;
/*     */ 
/* 272 */     if (map.get("info_id") != null)
/* 273 */       info_id = map.get("info_id").toString();
/*     */     else {
/* 275 */       return;
/*     */     }
/* 277 */     if (map.get("method") != null)
/* 278 */       method = map.get("method").toString();
/*     */     else {
/* 280 */       return;
/*     */     }
/*     */ 
/* 284 */     up_num = getCommentUp_num(info_id);
/* 285 */     down_num = getCommentDown_num(info_id);
/*     */ 
/* 287 */     if ((method != null) && (!method.equals(""))) {
/* 288 */       if (method.equals("1")) {
/* 289 */         up_num = 1 + up_num;
/*     */       }
/* 291 */       else if (method.equals("-1")) {
/* 292 */         down_num = 1 + down_num;
/*     */       }
/*     */ 
/*     */     }
/*     */ 
/* 297 */     Map params = new Hashtable();
/* 298 */     if ((info_id != null) && (!info_id.equals(""))) params.put("info_id", info_id);
/* 299 */     params.put("up_num", "" + up_num);
/* 300 */     params.put("down_num", "" + down_num);
/*     */     try
/*     */     {
/* 304 */       dbmMgr.update("updateNewsCommentNums", params);
/*     */     } catch (ApplicationException e) {
/* 306 */       e.printStackTrace();
/*     */     }
/*     */   }
/*     */ 
/*     */   public int getCommentUp_num(String info_id)
/*     */   {
/* 312 */     Map params = new Hashtable();
/*     */ 
/* 314 */     if ((info_id != null) && (!info_id.equals(""))) params.put("info_id", info_id);
/*     */ 
/* 316 */     List commentList = this.queryList.getList("getTi_newscommentsByID", params);
/* 317 */     String up_num = "";
/* 318 */     Hashtable commentMap = new Hashtable();
/* 319 */     if ((commentList != null) && (commentList.size() > 0)) commentMap = (Hashtable)commentList.get(0);
/* 320 */     if (commentMap.get("up_num") != null) up_num = commentMap.get("up_num").toString();
/* 321 */     int i_up_num = 0;
/* 322 */     i_up_num = Integer.parseInt(up_num);
/*     */ 
/* 325 */     return i_up_num;
/*     */   }
/*     */ 
/*     */   public int getCommentDown_num(String info_id)
/*     */   {
/* 330 */     Map params = new Hashtable();
/*     */ 
/* 332 */     if ((info_id != null) && (!info_id.equals(""))) params.put("info_id", info_id);
/*     */ 
/* 334 */     List commentList = this.queryList.getList("getTi_newscommentsByID", params);
/* 335 */     String down_num = "";
/* 336 */     Hashtable commentMap = new Hashtable();
/* 337 */     if ((commentList != null) && (commentList.size() > 0)) commentMap = (Hashtable)commentList.get(0);
/* 338 */     if (commentMap.get("down_num") != null) down_num = commentMap.get("down_num").toString();
/* 339 */     int i_down_num = 0;
/* 340 */     i_down_num = Integer.parseInt(down_num);
/*     */ 
/* 343 */     return i_down_num;
/*     */   }
/*     */ 
/*     */   public List getListByPageAdmin(Object obj, int start, int limit)
/*     */   {
/* 348 */     Hashtable ti_newscomment = (Hashtable)obj;
/* 349 */     if (start == 0)
/* 350 */       start = 0;
/*     */     else {
/* 352 */       start = (start - 1) * limit;
/*     */     }
/* 354 */     ti_newscomment.put("start", Integer.valueOf(start));
/* 355 */     ti_newscomment.put("limit", Integer.valueOf(limit));
/* 356 */     return this.queryList.getList("getListByTi_newscommentPageAdmin", ti_newscomment);
/*     */   }
/*     */ 
/*     */   public int getCountByObjAdmin(Object obj)
/*     */   {
/* 367 */     Hashtable ti_newscomment = (Hashtable)obj;
/*     */ 
/* 369 */     List list = this.queryList.getList("getCountByObjTi_newscommentAdmin", ti_newscomment);
/* 370 */     int count = 0;
/* 371 */     if ((list != null) && (list.size() > 0)) {
/* 372 */       Hashtable newsMap = (Hashtable)list.get(0);
/* 373 */       if ((newsMap.get("count") != null) && (!newsMap.get("count").toString().equals(""))) {
/* 374 */         count = Integer.parseInt(newsMap.get("count").toString());
/*     */       }
/*     */     }
/* 377 */     return count;
/*     */   }
/*     */ }

/* Location:           F:\电商\commons-utils.jar
 * Qualified Name:     com.lmpop.trade.ti_newscomment.Ti_newscommentInfo
 * JD-Core Version:    0.6.0
 */